﻿using nRoute.Components;
using nRoute.Components.Routing;
using System.Runtime.Serialization;

namespace nRoute.Navigation
{
    public class NavigationRequest
		 : UrlRequest
    {

#region Constructors

        public NavigationRequest(string url)
            : this(url, null, null, NavigateMode.New) { }

        public NavigationRequest(string url, string siteArea)
            : this(url, null, siteArea, NavigateMode.New) { }

        public NavigationRequest(string url, ParametersCollection requestParameters)
		    : this(url, requestParameters, null, NavigateMode.New) { }

        public NavigationRequest(string url, ParametersCollection requestParameters, string siteArea)
		    : this(url, requestParameters, siteArea, NavigateMode.New) { }

        public NavigationRequest(string url, NavigateMode navigationMode)
            : this(url, null, null, navigationMode) { }

        public NavigationRequest(string url, string siteArea, NavigateMode navigationMode)
            : this(url, null, siteArea, navigationMode) { }

        public NavigationRequest(string url, ParametersCollection requestParameters, NavigateMode navigationMode)
            : this(url, requestParameters, null, navigationMode) { }

        public NavigationRequest(string url, ParametersCollection requestParameters, string siteArea, NavigateMode navigationMode)
            : base(url, requestParameters, siteArea) 
        {
            base.ServiceState = new NavigateMode?(navigationMode);
        }

#endregion

#region Properties

        public NavigateMode NavigationMode
        {
            get
            {
                return (base.ServiceState as NavigateMode?).GetValueOrDefault(NavigateMode.New);
            }
        }

        internal IDisposableToken Token { get; set; }

#endregion

#region Methods

        public NavigationRequest Clone()
        {
            return new NavigationRequest(this.RequestUrl, this.RequestParameters, this.SiteArea, this.NavigationMode);
        }

#endregion

    }
}
